package www.com.springboot_20200312.rabbitmqDemo.FanoutExchange.producer;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import www.com.springboot_20200312.rabbitmqDemo.FanoutExchange.message.DemoFanoutMessage;

/**
 * @program: springboot_20200312
 * @ClassName Demo01Producer
 * @description:
 * @author: jht
 * @create: 2021-12-07 10:25
 * @Version 1.0
 **/
@Component
public class DemoFanoutProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void syncSend(Integer id) {
        // 创建 Demo02Message 消息
        DemoFanoutMessage message = new DemoFanoutMessage();
        message.setId(id);
        // 同步发送消息
        rabbitTemplate.convertAndSend(DemoFanoutMessage.EXCHANGE, null, message);
    }
}
